d7d04aa090e47a82b4e8ef863435936a9819539a,src/org/citydb/modules/citygml/importer/database/xlink/resolver/DBXlinkSplitter.java,DBXlinkSplitter,appearanceXlinks,#,278

Before Change


			CacheTable texParamTableTable = cacheTableManager.getCacheTable(CacheTableModelEnum.TEXTUREPARAM);
			boolean existsLinearRingTable = cacheTableManager.existsCacheTable(CacheTableModelEnum.LINEAR_RING);

			int max = 0, current = 0;
			if (texCoordTable != null && existsLinearRingTable) max += (int)texCoordTable.size();
			if (texParamTableTable != null) max += (int)texParamTableTable.size();

			// first step: resolve texture coordinates
			if (texCoordTable != null && existsLinearRingTable) {
				CacheTable linearRingTable = cacheTableManager.getCacheTable(CacheTableModelEnum.LINEAR_RING);
				texCoordTable.createIndexes();
				linearRingTable.createIndexes();

				stmt = texCoordTable.getConnection().createStatement();
				rs = stmt.executeQuery(new StringBuilder("select tc.ID, tc.GMLID, tc.TEXPARAM_GMLID, tc.TARGET_ID, lr.PARENT_ID, lr.REVERSE from ").append(texCoordTable.getTableName()).append(" tc ")
						.append(" join ").append(linearRingTable.getTableName()).append(" lr on tc.GMLID=lr.GMLID where lr.RING_NO = 0").toString());

				while (rs.next() && shouldRun) {
					eventDispatcher.triggerEvent(new StatusDialogProgressBar(++current, max, this));

					long id = rs.getLong("ID");
					String gmlId = rs.getString("GMLID");
					String texParamGmlId = rs.getString("TEXPARAM_GMLID");
					long targetId = rs.getLong("TARGET_ID");
					long surfaceGeometryId = rs.getLong("PARENT_ID");
					boolean reverse = rs.getBoolean("REVERSE");

					DBXlinkTextureCoordList xlink = new DBXlinkTextureCoordList(
							id,
							gmlId,
							texParamGmlId,
							targetId);

					xlink.setSurfaceGeometryId(surfaceGeometryId);
					xlink.setReverse(reverse);

					xlinkResolverPool.addWork(xlink);
				}

				rs.close();
				stmt.close();
			}

			// second step: resolve texture param other than texture coordinates
			if (texParamTableTable != null) {			
				stmt = texParamTableTable.getConnection().createStatement();
				rs = stmt.executeQuery("select * from " + texParamTableTable.getTableName());

				while (rs.next() && shouldRun) {
					eventDispatcher.triggerEvent(new StatusDialogProgressBar(++current, max, this));

					long id = rs.getLong("ID");
					String gmlId = rs.getString("GMLID");

After Change


			if (texParamTableTable != null) max += (int)texParamTableTable.size();
			
			LOG.info("Resolving appearance XLinks...");
			eventDispatcher.triggerEvent(new StatusDialogProgressBar(ProgressBarEventType.INIT, max, this));
			eventDispatcher.triggerEvent(new StatusDialogMessage(Language.I18N.getString("import.dialog.appXlink.msg"), this));

			// first step: resolve texture coordinates
			if (texCoordTable != null && existsLinearRingTable) {
				CacheTable linearRingTable = cacheTableManager.getCacheTable(CacheTableModelEnum.LINEAR_RING);
				texCoordTable.createIndexes();
				linearRingTable.createIndexes();

				stmt = texCoordTable.getConnection().createStatement();
				rs = stmt.executeQuery(new StringBuilder("select tc.ID, tc.GMLID, tc.TEXPARAM_GMLID, tc.TARGET_ID, lr.PARENT_ID, lr.REVERSE from ").append(texCoordTable.getTableName()).append(" tc ")
						.append(" join ").append(linearRingTable.getTableName()).append(" lr on tc.GMLID=lr.GMLID where lr.RING_NO = 0").toString());

				while (rs.next() && shouldRun) {
					eventDispatcher.triggerEvent(new StatusDialogProgressBar(ProgressBarEventType.UPDATE, 1, this));

					long id = rs.getLong("ID");
					String gmlId = rs.getString("GMLID");
					String texParamGmlId = rs.getString("TEXPARAM_GMLID");
					long targetId = rs.getLong("TARGET_ID");
					long surfaceGeometryId = rs.getLong("PARENT_ID");
					boolean reverse = rs.getBoolean("REVERSE");

					DBXlinkTextureCoordList xlink = new DBXlinkTextureCoordList(
							id,
							gmlId,
							texParamGmlId,
							targetId);

					xlink.setSurfaceGeometryId(surfaceGeometryId);
					xlink.setReverse(reverse);

					xlinkResolverPool.addWork(xlink);
				}

				rs.close();
				stmt.close();
			}

			// second step: resolve texture param other than texture coordinates
			if (texParamTableTable != null) {			
				stmt = texParamTableTable.getConnection().createStatement();
				rs = stmt.executeQuery("select * from " + texParamTableTable.getTableName());

				while (rs.next() && shouldRun) {
					eventDispatcher.triggerEvent(new StatusDialogProgressBar(ProgressBarEventType.UPDATE, 1, this));

					long id = rs.getLong("ID");
					String gmlId = rs.getString("GMLID");
					DBXlinkTextureParamEnum type = DBXlinkTextureParamEnum.fromInt(rs.getInt("TYPE"));
					int isTexPara = rs.getInt("IS_TEXTURE_PARAMETERIZATION");
					String texParamGmlId = rs.getString("TEXPARAM_GMLID");
					String worldToTexture = rs.getString("WORLD_TO_TEXTURE");

					// set initial context...
					DBXlinkTextureParam xlink = new DBXlinkTextureParam(
							id,
							gmlId,
							type);

					xlink.setTextureParameterization(isTexPara != 0);
					xlink.setTexParamGmlId(texParamGmlId);
					xlink.setWorldToTexture(worldToTexture);

					xlinkResolverPool.addWork(xlink);
				}

				rs.close();
				stmt.close();
			}

			if (!shouldRun)
				return;

			// third step: import texture images and world files
			if (cacheTableManager.existsCacheTable(CacheTableModelEnum.TEXTURE_FILE)) {		
				CacheTable temporaryTable = cacheTableManager.getCacheTable(CacheTableModelEnum.TEXTURE_FILE);

				LOG.info("Importing texture images...");
				eventDispatcher.triggerEvent(new StatusDialogProgressBar(ProgressBarEventType.INIT, (int)temporaryTable.size(), this));
				eventDispatcher.triggerEvent(new StatusDialogMessage(Language.I18N.getString("import.dialog.texImg.msg"), this));

				stmt = temporaryTable.getConnection().createStatement();